<?php

	// this branch executes after first writing a post and hitting the submit button
	if (!empty($_POST['action']) && $_POST['action'] == 'login')
	{
		
		escape($_POST);
		$errors = array();
		
		$_SESSION['user_ip'] = $_SERVER['REMOTE_ADDR'];
		$_SESSION['referer'] = BASE_URL . 'post/';
		
		// validation
		if ($username == '')
		{
			$errors['username'] = $translations['member']['username_error'];
		}
		if ($password == '')
		{
			$errors['password'] = $translations['member']['password_error'];
		}
		
		


		// no errors, go to review page
		if (empty($errors))
		{

		$_SESSION['LOGIN_username'] = $_POST['username'];
		$_SESSION['LOGIN_userid'] = 1;
		
			

			redirect_to(BASE_URL . 'myproperty/');
			exit;
		}
		// if errors exist, go back and edit the post
		else
		{
			$smarty->assign('errors', $errors);
		}
	}
	$template = 'member-login.tpl';
?>